import 'package:lx_widgets_library/model/auth3rd/auth_3rd_type.dart';
import 'auth_3rd_impl.dart';
import 'auth_3rd_model.dart';

// 第三方登录管理器
class Auth3rdManager extends IAuth3rdManager {
  // 第三方登录类型
  final Auth3rdType auth3rdType;
  //
  final String googleClientIdAndroid;
  //
  final String googleClientIdIos;
  //
  final String googleServiceId;

  // 第三方登录管理器
  IAuth3rdManager? _auth3rdManager;

  Auth3rdManager(
    this.auth3rdType,
    this.googleClientIdAndroid,
    this.googleClientIdIos,
    this.googleServiceId,
  ) {
    switch (auth3rdType) {
      case Auth3rdType.google:
        _auth3rdManager = GoogleAuthManager(
            googleClientIdAndroid, googleClientIdIos, googleServiceId);
        break;
      case Auth3rdType.apple:
        _auth3rdManager = AppleAuthManager();
        break;
      default:
        throw UnimplementedError('Not support [$auth3rdType] yet');
    }
  }

  @override
  Future<Auth3rdModel> auth() {
    return _auth3rdManager!.auth();
  }
}
